#include "mcserializeutil.h"

namespace MCCommon
{ 

void Write
(
    std::ostream& os,
    int iValue
)
{
    os<<iValue; 
}

void Write
(
    std::ostream& os,
    short iValue
)
{
    os<<iValue;    
}

   
void Write
(
    std::ostream& os,
    unsigned int iValue
) 
{
    os<<iValue;
}

void Write
(
    std::ostream& os,
    bool bValue
) 
{
    char v = bValue ? 't' : 'f';
    os << v; 
}

void Write
(
    std::ostream& os,
    long lValue
) 
{
    os<<lValue;
}

void Write
(
    std::ostream& os,
    double dValue
) 
{
    os<<dValue;
}

void Write
(
    std::ostream& os,
    const std::string& sValue
) 
{
    os<<sValue;
}

bool Read
(
    std::istream& is,
    int& iValue
)
{
    is >>iValue;
    return true;
}

bool Read
(
    std::istream& is,
    short& iValue
)
{
    is >>iValue;
    return true;
}

bool Read
(
    std::istream& is,
    unsigned int& iValue
)
{
    is >> iValue;
    return true;
}

bool Read
(
    std::istream& is,
    long& iValue
)
{
    is >> iValue;
    return true;
}

bool Read
(
    std::istream& is,
    double& dValue
)
{
    is >> dValue;
    return true;
}

bool Read
(
    std::istream& is,
    std::string& sValue
)
{
    sValue.clear();
    is >> sValue;
    return true;
}

bool Read
(
    std::istream& is,
    bool& bValue
)
{   
    char tf;
    is.read( &tf, 1 );
    bValue = ( tf == 't' ? true : false );
    return true;   
}

} // end of namespace.

   
